package service.impl;

import java.util.ArrayList;
import java.util.List;

import javax.websocket.ClientEndpointConfig;

import dao.ClientDao;
import dao.impl.ClientDaoImpl;
import po.Client;
import service.ClientService;

public class ClientServiceImpl implements ClientService{

	@Override
	public int addClient(Client c) {
		ClientDao clientDaoImpl = new ClientDaoImpl();
		int m = clientDaoImpl.addClient(c);
		return m;
	}


	@Override
	public int CheckClient(Client c) {
		ClientDao clientDaoImpl = new ClientDaoImpl();
		List<Client> clientList = new ArrayList<Client>();
		clientList = clientDaoImpl.queryClient();
		for(Client client:clientList){
			String cUserName = client.getcUsername();
			String cPassword = client.getcPassword();			
			if(c.getcUsername().equals(cUserName)&&c.getcPassword().equals(cPassword)){
				return client.getcId();
			}
		}
		
		return 0;
	}
	
}
